/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dingnangen
 */
@Entity
@Table(name = "manager")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Manager.findAll", query = "SELECT m FROM Manager m"),
    @NamedQuery(name = "Manager.findByIdmanager", query = "SELECT m FROM Manager m WHERE m.idmanager = :idmanager")})
public class Manager implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idmanager")
    private Integer idmanager;
    @JoinTable(name = "manager_depot", joinColumns = {
        @JoinColumn(name = "idmanager", referencedColumnName = "idmanager")}, inverseJoinColumns = {
        @JoinColumn(name = "iddepot", referencedColumnName = "iddepot")})
    @ManyToMany
    private List<Depot> depotList;
    @JoinColumn(name = "iduser", referencedColumnName = "iduser")
    @ManyToOne(optional = false)
    private User iduser;

    public Manager() {
    }

    public Manager(Integer idmanager) {
        this.idmanager = idmanager;
    }

    public Integer getIdmanager() {
        return idmanager;
    }

    public void setIdmanager(Integer idmanager) {
        this.idmanager = idmanager;
    }

    @XmlTransient
    public List<Depot> getDepotList() {
        return depotList;
    }

    public void setDepotList(List<Depot> depotList) {
        this.depotList = depotList;
    }

    public User getIduser() {
        return iduser;
    }

    public void setIduser(User iduser) {
        this.iduser = iduser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idmanager != null ? idmanager.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Manager)) {
            return false;
        }
        Manager other = (Manager) object;
        if ((this.idmanager == null && other.idmanager != null) || (this.idmanager != null && !this.idmanager.equals(other.idmanager))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.entity.Manager[ idmanager=" + idmanager + " ]";
    }
    
}
